package com.haiyou.dc.aggregate.list;

public class MyLinkList02 {

    private Node first;
    private Node last;


    public void add(Object object) {
        Node node = new Node(object);

        if (first == null) {
            first = node;
            last = node;
        } else {
            node.setPrevious(last);
            node.setNext(null);

            last.setNext(node);
            last = node;
        }
    }

    public void show() {
        Node temp = first;
        while (temp != null) {
            System.out.println(temp.getElement());
            temp = temp.getNext();
        }
    }

    public static void main(String[] args) {
        MyLinkList02 myLinkList02 = new MyLinkList02();
        myLinkList02.add("a");
        myLinkList02.add("b");
        myLinkList02.add("c");

        myLinkList02.show();
    }
}
